Add getters for 'demand' and 'controlMode' in FakeMotor#77
Merged
Conversation
This is in preparation for making the 'demand' field package-scope. Now that FakeMotor has an 'isStopped' field, allowing code outside of FakeMotor to directly update the value is error-prone.
vdikov
approved these changes
Oct 13, 2025
vdikov
reviewed
Oct 13, 2025
| private ControlMode controlMode = ControlMode.VOLTAGE; | ||
|
|
||
| /** Gets the most recently applied demand value for this motor. */ | ||
| public final double getDemand() { |
Contributor
There was a problem hiding this comment.
I was wondering the other day, if we want to make the Motor abstraction be a generic that takes the control mode as a template parameter. Then, the getDemand() should return demand in the type that matches the control mode - Position, Velocity, Voltage, etc.
This way, we could potentially prevent improper uses of the demand value (e.g., use a demand value as a voltage, from a motor that has been set up for speed).
Contributor
Author
There was a problem hiding this comment.
@vdikov That's an interesting idea. Perhaps create an issue tracking that?
kcooney
added a commit
to Prospect-Robotics/Robot2025
that referenced
this pull request
Oct 15, 2025
This includes the following: - Prospect-Robotics/lib2813#46 - Prospect-Robotics/lib2813#67 - Prospect-Robotics/lib2813#71 - Prospect-Robotics/lib2813#75 - Prospect-Robotics/lib2813#77 - Prospect-Robotics/lib2813#78 - Prospect-Robotics/lib2813#80 - Prospect-Robotics/lib2813#81 - Prospect-Robotics/lib2813#85
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is in preparation for making the 'demand' field package-scope. Now that FakeMotor has an 'isStopped' field, allowing code outside of FakeMotor to directly update the value is error-prone.